import fnmatch
import os

for file in os.listdir('.'):
    if fnmatch.fnmatch(file, '*.txt'):
        print(file)
    elif fnmatch.fnmatchcase(file, '*.txt'):
        print("case match: ",file)
        
file=['1.txt','2.txt','3.gif']
fnmatch.filter(file,'*.txt')
# --> ['1.txt', '2.txt']
